#include ("/_includes/_layout.html")
#@layout("点步插件平台--应用中心", "wxmall,点步科技", "Wxmall社区","wxmall")
#define css()
<style>
.iipxjf{
	border-radius: 4px;
	border: 1px solid #e7eaec;
	overflow: hidden;
}
.jsONNa{
	float:left;
	text-align: center;
}
.dgMvjz,.jtiAZd{
	font-size: 10px;
}
.bjmPCA {
    font-size: 14px;
    color: #313131;
    margin: 10px 0;
}
.dzlqyF {
    display: inline-block;
    vertical-align: middle;
    margin-left: 5px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid #03a854;
}

.iIjmuk-box{
    border-radius: 4px;
	float: left;
	padding:0px 15px 15px;
	
}
.iIjmuk {
    position: relative;
    background-color: #fff;
    margin-bottom: 20px;
    border-radius: 4px;
}
.jIeewA{
	padding: 16px;
	border: 1px solid #e7eaec;
	padding: 10px;
	overflow: hidden;
	background-color: #fbfcfd
}

.eCNVCe {
    overflow: hidden;
    position: relative;
}
.gRCHRu {
    width: 100%;
    height: 100%;
    margin-right: 5px;
    margin-top: 5px;
}
.cvtaBP {
    height: 24px;
    line-height: 24px;
    font-size: 14px;
    position: relative;
    left:10px;
    margin: 0px;
}
.cvtaDESC{
	font-size: 12px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap; 
	position: relative;
    left:10px;
    color: #979899;
    width: 60%;
    margin: 0px;
}
.explain-box{
	padding-top: 15px;
	padding-bottom: 15px;
}
.deadline-box{
	text-align: center;
	position: absolute;
	width: 100%;
	bottom: 15px;
}
.irthqT{
	font-size: 14px;
    color: #3e3e3e;
    margin-top: 17px;
    margin-bottom: 13px;
}
.kNaOOG {
    border-radius: 33px;
    background-color: #f5f5f5;
    display: inline-block;
    padding:6px 20px;
    margin: 20px auto 0px;
    color: #565656;
}
.kNaOOG .font-bold{
	padding: 20px 20px;
}
</style>
#end
#define content()
<div class="wrapper wrapper-content">
	<div class="ibox-content" style="padding: 20px 0px;">
		<div class="col-md-3" style="padding-right: 0px;">
            <div class="ibox float-e-margins" >
                <div class="ibox-content" style="padding:0px;">
                	#if(session.weapp_in_session?? && session.weapp_in_session.service_type!=0)
                	<div class="file-manager">
                        <h5>常用应用</h5>
                        <ul class="folder-list" style="padding: 0">
                            <li><a data-app-id="1" menu-id="40" data-url="template/message" href="javascript:void(0)"><i class="fa fa-folder"></i>消息群发</a></li>
							<li><a data-app-id="7" menu-id="47" data-url="task/poster" href="javascript:void(0)"><i class="fa fa-folder"></i>任务宝</a></li>
                            <li><a data-app-id="8" menu-id="54" data-url="jifen/poster" href="javascript:void(0)"><i class="fa fa-folder"></i>积分宝</a></li>
                        </ul>
                        <div class="clearfix"></div>
                    </div>
                    #end
                    #if (session.weapp_in_session??)
                    <div class="euIMud">
                      <div class="iipxjf">
						<div class="dropdown profile-element" style="margin-bottom: 5px;text-align: center;margin-top: 30px;padding: 10px 0px;">
		                    <span><img alt="image" style="width: 60px;height: 60px;border-radius: 50%" src="#(session.weapp_in_session.head_img)" /></span>
		                    <span class="clear"><span class="block m-t-xs irthqT"><strong class="font-bold" style="font-size: 12px;">#(session.weapp_in_session.nick_name)</strong></span></span>
		                    <span class="clear"><span class="block m-t-xs kNaOOG"><strong class="font-bold" style="font-size: 12px;">粉丝数:#(session.weapp_in_session.fans_count)</strong></span></span>
		                </div>
		                <div style="margin: 50px 15px 30px;overflow: hidden;padding-top: 50px;border-top: 1px solid #e7eaec;">
			                <div class="first-card sc-bGbJRg jsONNa col-md-4" style="padding-left: 15px;">
							  <div class="sc-drMfKT dgMvjz">昨日净增粉丝</div>
							   <div class="sc-bEjcJn bjmPCA">#if(session.weapp_in_session.add_fans_count)#(session.weapp_in_session.add_fans_count)#else N/A #end</div>
							   <!-- <div class="sc-ePZHVD jtiAZd">
							    <span><span style="color: rgb(149, 149, 149);">300%</span>
							     <div class="sc-likbZx dzlqyF"></div></span>
							   </div> -->
							</div>
							<div class="first-card sc-bGbJRg jsONNa col-md-4">
							  <div class="sc-drMfKT dgMvjz">昨日互动粉丝数</div>
							   <div class="sc-bEjcJn bjmPCA">#if(session.weapp_in_session.ita_fans_count)#(session.weapp_in_session.ita_fans_count)#else N/A #end</div>
							   <!-- <div class="sc-ePZHVD jtiAZd">
							    <span><span style="color: rgb(149, 149, 149);">300%</span>
							     <div class="sc-likbZx dzlqyF"></div></span>
							   </div> -->
							</div>
							<div class="first-card sc-bGbJRg jsONNa col-md-4" style="padding-right: 15px;">
							  <div class="sc-drMfKT dgMvjz">取消关注粉丝数</div>
							   <div class="sc-bEjcJn bjmPCA">#if(session.weapp_in_session.del_fans_count)#(session.weapp_in_session.del_fans_count)#else N/A #end</div>
							   <!-- <div class="sc-ePZHVD jtiAZd">
							    <span><span style="color: rgb(149, 149, 149);">300%</span>
							     <div class="sc-likbZx dzlqyF"></div></span>
							   </div> -->
							</div>
						</div>
                      </div>
                    </div>
                    #end
                </div>
            </div>
        </div>
        <div class="col-md-9" style="padding-left: 0px;padding-bottom:100px">
	        <div class="col-sm-12 col-md-12" style="padding-bottom: 20px;" id="commend">
				<div class="col-sm-12 col-md-12" style="background-color: #f5f5f5;color: #333;border-color:#d1dade;height: 35px;line-height: 35px;font-size: 18px;">通用应用</div>
	         </div>
	        <div class="col-sm-12 col-md-12" style="padding-bottom: 20px;" id="redpack">
				<div class="col-sm-12 col-md-12" style="background-color: #f5f5f5;color: #333;border-color:#d1dade;height: 35px;line-height: 35px;font-size: 18px;">红包应用</div>
	         </div>
	        <div class="col-sm-12 col-md-12" style="padding-bottom: 20px;" id="fans">
				<div class="col-sm-12 col-md-12" style="background-color: #f5f5f5;color: #333;border-color:#d1dade;height: 35px;line-height: 35px;font-size: 18px;">互动吸粉</div>
	         </div>
	        <!-- <div class="col-sm-12 col-md-12" style="padding-bottom: 20px;display: none;" id="marketing">
				<div class="col-sm-12 col-md-12" style="background-color: #f5f5f5;color: #333;border-color:#d1dade;height: 35px;line-height: 35px;font-size: 18px;">交易玩法</div>
	         </div> -->
        </div>
    </div>
</div>
<script id="tmp" type="text/html">
<div class="iIjmuk-box col-md-3">
	<div class="iIjmuk">
		<a href="javascript:void(0);" data-url="{appIndexPage}" data-id="{id}" app-menu-id="{appMenuId}" app-sec-menu-id="{appSecMenuId}">
			<div class="jIeewA">
				<div style="width:49px; height:49px; display:inline-block; float: left"><img alt="image" class="gRCHRu" src="{appImage}"></div>
				<p class="sc-gVyKpa cvtaBP">{appName}</p>
				<p class="sc-gVyKpa cvtaDESC">{appDesc}</p>
				<p class='sc-gVyKpa cvtaDESC {isfree}' style='color: blue;'>&nbsp;</p>
				<i class="fa fa-angle-right fa-2x" style="position: absolute; right: 20px;top:22px;" aria-hidden="true"></i>
			</div>
		</a>
	</div>
</div>
</script>    
#define script()
<script type="text/javascript">
$(document).ready(function(){
	#if(activity??)
		#if(!isJoin??)
			actLayer();
		#end
	#end	
	$("#activityBtn").click(function(){
		actLayer();
	})
	
	getApps();
});
function actLayer(){
	obz.open("","#(webctx)/activity/");
}
function getAppEndDate(){
	obz.ajaxJson("#(webctx)/app/getAppEndDate", {}, function(resp){
		if(resp.code == 200){
			var list = resp.data;
			for(var i=0;i<list.length;i++){
				var text =list[i].endDate.substr(0,10)+"到期";
				$("a[data-id='"+list[i].appId+"']").find("p[class='sc-gVyKpa cvtaDESC flag']").text(text);
			}
		}
	});
} 

function getApps(){
	obz.ajaxJson("#(webctx)/app/getApps", {}, function(resp){
		if(resp.code == 200){
			var list = resp.data;
			
			for(var i=0;i<list.length;i++){
				var app = list[i];
				app.appImage = "#(webctx)"+"/"+app.appImage;
				if(!app.isfree){
					app.isfree = "flag";
				}
				if(app.appCategory == 0){
					var html = formatTemplate(app, $("#tmp").html());
					$("#commend").after(html);
				}else if(app.appCategory == 1){
					var html = formatTemplate(app, $("#tmp").html());
					$("#redpack").after(html);
				}else if(app.appCategory == 2){
					var html = formatTemplate(app, $("#tmp").html());
					$("#fans").after(html);
				}
				/* else if(app.appCategory == 3){
					var html = formatTemplate(app, $("#tmp").html());
					$("#marketing").after(html);
				} */
			}
			
			var weapp_index_type = "#(session.weapp_in_session.service_type??)";
			if(weapp_index_type=="0"){
				$("#redpack").hide();
				$("#fans").hide();
			}
			getAppEndDate();
		}
		
		$(".folder-list").find("a").click(function(){
			setCookie("app_id_in_cookie", $(this).attr("data-app-id") || "");
			var url = $(this).attr("data-url");
			location.href = "#(webctx)/"+url;
		});
		$(".iIjmuk").find("a").click(function(){
			setCookie("app_id_in_cookie", $(this).attr("data-id") || "");
			var url = $(this).attr("data-url")
			location.href = "#(webctx)/"+url;
		});
	});
}

function formatTemplate(dta, tmpl) {  
    var format = {  
        name: function(x) {  
            return x  
        }  
    };  
    return tmpl.replace(/{(\w+)}/g, function(m1, m2) {  
        if (!m2)  
            return "";  
        return (format && format[m2]) ? format[m2](dta[m2]) : dta[m2];  
    });  
}
</script>
#end
#end
